<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            margin: 100px auto;

        }
        span {
            float: left;
            display: block;
            height: 50px;
            width: 50px;
            background-color: #333;
            color: #fff;
            text-align: center;
            line-height: 50px;
            margin-left: 5px;
        }
    </style>
</head>
<body>
    <div>
        <span class="hour">1</span>
        <span class="minute">2</span>
        <span class="second">3</span>
    </div>
    <script>
        var hour = document.querySelector('.hour');
        var minute = document.querySelector('.minute');
        var second = document.querySelector('.second');
        var time2 = +new Date('2022-9-15 18:00:00');
        countDown();
        setInterval(countDown,1000);
        function countDown() {
        var time1 = +new Date()
        var timer = (time2 - time1) / 1000;
        var h = parseInt(timer /60 / 60 % 24);
        h = h < 10 ? '0' + h :h;
        hour.innerHTML = h;
        var m = parseInt(timer / 60 %60);
        m = m < 10 ? '0' + m :m;
        minute.innerHTML = m;
        var s = parseInt(timer %60);
        s = s < 10 ? '0' + s :s;
        second.innerHTML = s;
     }
    </script>
</body>
</html>